package com.gxa.meiye.admin.shop.config;

import com.gxa.meiye.admin.shop.interceptor.TokenInterceptors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author chen
 * @date 2022/7/7 11:35
 */

@Configuration
public class InterceptorConfigs implements WebMvcConfigurer {
    // 注册拦截器, 就调用addInterceptors

    @Autowired
    TokenInterceptors tokenInterceptor = null;
//TODO
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        token的拦截器工作时,放行大多数请求,只拦截核心业务:搜索/订单/购物车/支付
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/shopMain/**")
                .addPathPatterns("/shopOrder/**")
                .addPathPatterns("/shopService/**")
                .addPathPatterns("/shopFinance/**")
                .addPathPatterns("/shopInstall/**");
    }
}
